#!/usr/bin/perl -w

# This is a test program for fsmon - it will run it every 30 seoncds
# until control C - issuing error/log/warning messages to standard output.
#
# It requires the application to run against as the command line argument
#
#
BEGIN {
	push @INC,"/usr/local/cluster/lib/perl","/sbin/cluster/lems/modules",".";
}

use English;
use File::Basename;
$_PRG=basename($0);

sub logmsg {
	print "LOG  : $_[0]\n";
}

sub logwarn {
	print "WARN : $_[0]\n";
}

sub errmsg {
	print "ERROR: $_[0]\n";
	exit($_[1]);
}

if(!defined($ARGV[0])) {
	die("Usage: $_PRG application");
}

use procmon;
$file=$ARGV[0];
if(exists($ARGV[1])) {
	$delay=$ARGV[1];
} else {
	$delay=10;
}

if(! -f $file) {
	errmsg("File $file does not exist",2);
}

$procmon=new procmon($file);
exit(1) if ! defined($procmon);

while(1) {
	$r=$procmon->check;
	logmsg("Return call from check is $r");
	select(undef,undef,undef,$delay);
}


